package com.xin.uploadanddownload.test;

import java.io.*;
import java.nio.channels.FileChannel;

public class IOCopy {
    public static String srcPath="D:\\-7198455527216822856.doc";
    public static String destPath="D:\\mytest.doc";

    public static void main1(String[] args) throws Exception{
        InputStream inputStream = new FileInputStream(srcPath);
        OutputStream outputStream = new FileOutputStream("");
//        outputStream.
    }

    /**
     * jdk FileChannel方式
     * @param args
     * @throws Exception
     */
    public static void main(String[] args) throws Exception{
        FileChannel inputChannel = null;
        FileChannel outputChannel = null;
        try {
            inputChannel = new FileInputStream(srcPath).getChannel();
            outputChannel = new FileOutputStream(destPath).getChannel();
            outputChannel.transferFrom(inputChannel, 0, inputChannel.size());
        } finally {
            inputChannel.close();
            outputChannel.close();
        }
    }
}
